#MAKEFILE PPU DMA
C_CC=/usr/bin/ccache /usr/bin/ppu-gcc
ML_CC=ocamlopt
C_CFLAGS=-m32
ML_CFLAGS= -output-obj  -thread 
C_INCLUDES=-I/usr/local/lib/ocaml
C_LDFLAGS=-L /usr/local/lib/ocaml/ -L /usr/local/lib/ocaml/threads -L /usr/local/lib/ocaml/spu/
ML_LDFLAGS=unix.cmxa threads.cmxa bigarray.cmxa gero.cmxa
C_SRC=
ML_SRC=fma_ppu.ml 
C_OBJ= $(C_SRC:.c=.o)
ML_OBJ=fma_ppu.cmx
OBJS=$(C_OBJ) $(ML_OBJ) 
LIB= -cclib /usr/local/lib/ocaml/spu/fmaf4_spu.a -cclib /usr/local/lib/ocaml/spu/hello1_spu.a
EXEC=fma_ppu








%o: %c
	$(C_CC) $(C_CFLAGS) $(C_INCLUDES) -c $<

$(ML_OBJ): $(ML_SRC) 
		ocamlopt -thread threads.cmxa  -c $< -cclib -lthreads -cclib -lunix -cclib -lpthread -cclib -lbigarray -cclib -libgero 

exec2: $(OBJS)
	$(C_CC) $(C_CFLAGS) -o $(EXEC) $(OBJS) -L/usr/lib -L/opt/cell/sdk/usr/lib -R/opt/cell/sdk/usr/lib $(LIB) -lspe2 $(C_INCLUDES) $(C_LDFLAGS)  /usr/local/lib/ocaml/libunix.a /usr/local/lib/ocaml/bigarray.a /usr/local/lib/ocaml/gero.a /usr/local/lib/ocaml/libgero.a -lthreadsnat -lpthread  -lasmrun -ldl -lm -lbigarray -lgero -lsimdmath

exec: $(OBJS)
	ocamlopt unix.cmxa -thread threads.cmxa bigarray.cmxa gero.cmxa -o $(EXEC) -cclib -lthreads -cclib -lunix -cclib -lpthread -cclib /usr/local/lib/ocaml/gero.a -cclib /usr/local/lib/ocaml/libgero.a -cclib /usr/lib/libspe2.so $(LIB)  $(OBJS)

clean:
	rm -rf *.o *.a $(EXEC) *~  *.cm*  gen_*
